package com.hafu.dao;

import com.hafu.util.DbUtil;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * @Author:xiaohai 2072158919@qq.com 海航源
 * @Date: 2024/11/1  下午3:34
 * @Version 1.0
 * @description
 */
public class UserDao {
    public Boolean isLogin(String username, String password) throws SQLException {
        Connection connection = DbUtil.getConnection();

        String sql = "select * from userlist where name=? and pass=?";
        PreparedStatement preparedStatement = connection.prepareStatement(sql);
        preparedStatement.setString(1, username);
        preparedStatement.setString(2, password);
        ResultSet resultSet = preparedStatement.executeQuery();
        if (resultSet.next()) {
            return true;
        }
        return false;
    }
}
